# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=markupsafe
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python2-${_realname}" "${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=0.23
pkgrel=4
pkgdesc="Implements a XML/HTML/XHTML Markup safe string for Python (mingw-w64)"
arch=('any')
license=('custom')
url="https://pypi.python.org/pypi/MarkupSafe"
makedepends=("${MINGW_PACKAGE_PREFIX}-python2-setuptools" "${MINGW_PACKAGE_PREFIX}-python3-setuptools")
source=("https://pypi.python.org/packages/source/M/MarkupSafe/MarkupSafe-${pkgver}.tar.gz")
sha256sums=('a4ec1aff59b95a14b45eb2e23761a0179e98319da5a7eb76b56ea8cdc7b871c3')

build() {
  cd "${srcdir}"

  rm -rf python{2,3}-build
  for builddir in python{2,3}-build; do
    cp -r MarkupSafe-${pkgver} $builddir
    pushd ${builddir}
    ${MINGW_PREFIX}/bin/${builddir%-build} setup.py build
    popd
  done
}

package_python3-markupsafe() {
  depends=("${MINGW_PACKAGE_PREFIX}-python3")

  cd "${srcdir}/python3-build"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python3 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" -O1

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python3-${_realname}/LICENSE"
}

package_python2-markupsafe() {
  depends=("${MINGW_PACKAGE_PREFIX}-python2")

  cd "${srcdir}/python2-build"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python2 setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" -O1

  install -Dm644 LICENSE "${pkgdir}${MINGW_PREFIX}/share/licenses/python2-${_realname}/LICENSE"
}

package_mingw-w64-i686-python2-markupsafe() {
  package_python2-markupsafe
}

package_mingw-w64-i686-python3-markupsafe() {
  package_python3-markupsafe
}

package_mingw-w64-x86_64-python2-markupsafe() {
  package_python2-markupsafe
}

package_mingw-w64-x86_64-python3-markupsafe() {
  package_python3-markupsafe
}
